<?php
/**
 * 用户记录类
 * User: ZL
 * Date: 2016/6/3 20:40
 */

namespace backend\controllers;


use common\models\DAO\UserBuy;
use common\models\DAO\UserBuySearch;
use common\models\DAO\UserCharge;
use common\models\DAO\UserChargeSearch;
use common\models\DAO\UserTradeList;
use common\models\DAO\UserTradeListSearch;
use backend\commands\BaseAdminController;

class TransactionController extends BaseAdminController
{

    public function init()
    {
        parent::init(); // TODO: Change the autogenerated stub

    }

    /**
     * 用户出入金纪录列表
     */
    public function actionListCharge($id = 0)
    {
        $where = empty($id) ? [] : ['userID' => $id];

        return $this->CommonAdvanceList([
            'model' => new UserCharge(),
            'searchModel' => new UserChargeSearch(),
            'template' => 'list-charge',
            'where' => $where,
        ]);
    }

    /*
     * 用户交易记录列表
     */
    public function actionListDeal($id = 0)
    {
        $where = empty($id) ? [] : 'buyUserID='.$id.' OR sellUserID ='.$id;

        return $this->CommonAdvanceList([
            'model' => new UserTradeList(),
            'searchModel' => new UserTradeListSearch(),
            'template' => 'list-deal',
            'where' => $where,
        ]);
    }


    public function actionListBuy($id = 0)
    {
        $where = empty($id) ? [] : ['userID' => $id];
        
        return $this->CommonAdvanceList([
            'model' => new UserBuy(),
            'searchModel' => new UserBuySearch(),
            'template' => 'list-buy',
            'where' => $where,
        ]);
    }
}